package com.firefly.admin.common.enums;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;

public enum DataPermissionRangeEnum {
    PERSONAL_DATA("1", "个人数据"),
    ORG_DATA("2", "组织机构数据"),
    ORG_AND_SUB_ORG_DATA("3", "组织及以下组织数据"),
    ALL_DATA("4", "全部数据");
    private String type;
    private String name;

    DataPermissionRangeEnum(String type, String name) {
        this.type = type;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public static DataPermissionRangeEnum getDataPermissionByType(String type) {
        if (StringUtils.isBlank(type)) {
            return null;
        }
        for (DataPermissionRangeEnum permissionRangeEnum : DataPermissionRangeEnum.values()) {
            if (type.equals(permissionRangeEnum.getType())) {
                return permissionRangeEnum;
            }
        }
        return null;
    }
}
